package com.sabo.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BController {

    @GetMapping("/err")
    public ResponseEntity<String> err() {
        return new ResponseEntity<>("is error", HttpStatus.INTERNAL_SERVER_ERROR);
    }

    @GetMapping("/ok")
    public ResponseEntity<String> ok() {
        return new ResponseEntity<>("is ok", HttpStatus.OK);
    }

    @GetMapping("/sleep")
    public String sleep() {
        try {
            Thread.sleep(2000L);
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "ok";
    }

    @GetMapping("/exception")
    public Integer exception(@RequestParam Integer a, @RequestParam Integer b) {
        throw new RuntimeException("sadw");
//        return a / b;
    }

}
